import request from '@/utils/request';
import { channelListType } from '@/store/reducer/channel';

/** 获取所有的频道API */
export const getAllChannelAPI = () => {
  return request({
    url: '/v1_0/channels',
  });
};

/** 获取用户的频道API */
export const getUserChannelAPI = () => {
  return request({
    url: '/v1_0/user/channels',
  });
};

export type ChannelParamType = { channels: channelListType[] };
/** 设置用户的频道API */
export const setUserChannelAPI = (data: ChannelParamType) => {
  return request({
    url: '/v1_0/user/channels',
    method: 'patch',
    data,
  });
};

/** 删除指定用户的频道API */
export const delUserChannelAPI = (id: number) => {
  return request({
    url: `/v1_0/user/channels/${id}`,
    method: 'delete',
  });
};
